package com.oneguy.control.message;

import com.oneguy.Constants;
import com.oneguy.model.WeixinMessage;
import com.oneguy.control.util.JaxbUtil;
import org.apache.commons.lang.StringEscapeUtils;

/**
 * Created by ZuoShu on 16/12/6.
 */
public class MessageUtil {
    private static final String TAG = "MessageUtil";

    public static String getDefaultTip(WeixinMessage message) {
        return getTipMessage(message, Constants.Tip.TIP_DEFAULT);
    }

    public static String getTipSzSetFishMessage(WeixinMessage message) {
        return getTipMessage(message, Constants.Tip.TIP_SZ_SET_FISH);
    }

    public static String getTipSzSetFishTimerMessage(WeixinMessage message) {
        return getTipMessage(message, Constants.Tip.TIP_SZ_TIMER_SET_FISH);
    }

    public static String getTipSzSetFishSimpleMessage(WeixinMessage message) {
        return getTipMessage(message, Constants.Tip.TIP_SZ_SET_FISH_SIMPLE);
    }

    private static String getTipMessage(WeixinMessage message, String tip) {
        WeixinMessage reply = new WeixinMessage();
        reply.setToUserName(message.getFromUserName());
        reply.setFromUserName(message.getToUserName());
        reply.setContent(tip);
        reply.setCreateTime(String.valueOf(System.currentTimeMillis()));
        reply.setMsgType(Constants.T.TEXT);
        return StringEscapeUtils.unescapeXml(JaxbUtil.toXml(reply));
    }
}
